<?php
class Access_Model_Module
{
    public function getList()
    { 
        $front = Zend_Controller_Front::getInstance();
        $modules = $front->getControllerDirectory();
        $appData = array();
        
        foreach ($modules as $module => $path) {
            
            $realPath = realpath(
                $path . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR .
                "configs" . DIRECTORY_SEPARATOR . "app.ini"
            );
        
            if($realPath) {

                $handle = new Zend_Config_Ini($realPath);
                $config = $handle->toArray();
                $appData[$module]['controller'] = array();
                $appData[$module]['action'] = array();

                if(isset($config['app'])) {
                    $appData[$module]['app'] = $config['app'];
                } else {
                    $appData[$module]['app'] = $module;
                }
                
                if(isset($config['controllers'])) {

                    foreach ($config['controllers'] as $language => $controller) {
                        $appData[$module]['controller'] = $controller;
                        break;
                    }
                }
                unset($language);
                unset($controller);
                if(isset($config['actions'])) {
                    foreach ($config['actions'] as $language => $action) {
                        $appData[$module]['action'] = $action;
                        break;
                    }
                }
                unset($language);
                unset($controller);
            }
            
        }
        return $appData;
    }
}